﻿
// comAPP2View.h: CcomAPP2View 类的接口
//

#pragma once


#define DRAW_MODE_SELECT     0
#define DRAW_MODE_LINE 	     1
#define DRAW_MODE_RECT       2
#define DRAW_MODE_ELLIPSE	 3
#define DRAW_MODE_TEXT	     4



BOOL IfPointInFigure(POINT point, CFigure* MFigure);              //判断点是否属于图形
BOOL IfPointBelongToRectArea(POINT point, CRect mRect);           //判断点是否属于矩形
DOUBLE distanceCalculate(POINT point, POINT lineStart, POINT lineEnd);     //计算点线之间的距离


class CcomAPP2View : public CView
{
private:
	int currentMode;           //当前绘制模式
	bool M_Drawing;             //是否正在绘制
	bool MovingStart = FALSE;           //是否开始移动

	POINT ptS;                 //鼠标点下的起始点
	POINT ptE;                 //鼠标松开的结束点

protected: // 仅从序列化创建
	CcomAPP2View() noexcept;
	DECLARE_DYNCREATE(CcomAPP2View)

// 特性
public:
	CcomAPP2Doc* GetDocument() const;

// 操作
public:

// 重写
public:
	virtual void OnDraw(CDC* pDC);  // 重写以绘制该视图
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// 实现
public:
	virtual ~CcomAPP2View();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// 生成的消息映射函数
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnMenuFSelect();
	afx_msg void OnMenuFRect();
	afx_msg void OnMenuFLine();
	afx_msg void OnMenuFEllipse();
	afx_msg void OnMenuFText();
	afx_msg void OnUpdateMenuFEllipse(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuFLine(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuFRect(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuFSelect(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuFText(CCmdUI* pCmdUI);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMenuSetFillcolor();
	afx_msg void OnMenuSetFont();
	afx_msg void OnMenuSetPen();
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	afx_msg void OnMenuHelp();
};

#ifndef _DEBUG  // comAPP2View.cpp 中的调试版本
inline CcomAPP2Doc* CcomAPP2View::GetDocument() const
   { return reinterpret_cast<CcomAPP2Doc*>(m_pDocument); }
#endif

